/**
 * @auth: sce
 * @date: 1/8/18
 * @desc:  传入版本号，压缩目录
 **/
const zipper = require("zip-local"); //压缩文件


const zipFolder = (path,target) => {
    zipper.zip(path, function(error, zipped) {

        if(!error) {
            zipped.compress();

            // const buff = zipped.memory(); // get the zipped file as a Buffer

            // or save the zipped file to disk
            zipped.save(target, function(error) {
                if(!error) {
                    console.log(`saved ${target} successfully !`);
                }
            });
        }
    });
};

// const start = (release) => {
//
//     for(let i = 0, len = defaultPlatform.length; i < len; i++){
//         let path = `${rootPath}/${release}/${defaultPlatform[i]}`;
//         zipFolder(`${path}`,`${rootPath}/${defaultPlatform[i]}?release=${release}.zip`);
//     }
// };

module.exports = zipFolder;


